#pragma once
#include "OCMain/FileUtil.h"
#include "OCMain/StringUtil.h"
#include "OCMain/Singleton.h"

using namespace OCPP;

struct CAPFile {
	String date;
	String time;
	String file;
	bool operator < (const CAPFile& rhs)
	{
		return (date + time) < (rhs.date + rhs.time);
	}
};

using CAPFileVec = std::vector<CAPFile>;

class MyCap : public CSingleton<MyCap>
{
public:
	String get(String time, String product);
	String getCAP(String time, int z, int x0, int y0, int x1, int y1);
	String get3(String time, int z, int x0, int y0, int x1, int y1);
	void startTimer();
	std::set<String> query(String startTime, String endTime);

	String _dataPath;
	String _outputPath;
	int _threadNum = 1;
	int _expiredTime = 10;
	int interval = 6;
	//debug
	String fakeDate;
private:
	void init();
	void doJob();
	void clean();
	bool convert(const CAPFile& file, String dataPath, String ouputPath);
	int insert(String dateTime);
};
